<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// Route::get('/', function () {
//     // return view('welcome');
// });
Route::group(['middleware' => 'open'],function(){
Route::get('/home/index/layout','Home\LayoutController@layout');

// 前台
//忘记密码
Route::get('demo/forget', 'Demo\ForgetController@forget');
Route::post('demo/sendEmail', 'Demo\ForgetController@sendEmail');

//忘记密码
Route::get('/home/forget', 'Home\ForgetController@forget');
Route::post('/home/sendEmail', 'Home\ForgetController@sendEmail');
Route::post('/home/edit', 'Home\ForgetController@edit');
//找回密码
Route::get('/yanzheng','Home\ForgetController@yanzheng');
//注册
Route::get('/reg','Home\LoginController@reg');
Route::post('/doReg','Home\LoginController@doReg');
Route::get('/reg/ajax','Home\LoginController@ajaxE');
//登录
Route::get('/login','Home\LoginController@login');
Route::post('/doLogin','Home\LoginController@dologin');
Route::get('/logout','Home\LoginController@logout');

//商品详情页
Route::get('/detail/{id}','Home\DetailController@detail');
// 首页
Route::get('/', 'Home\ShopController@index');
Route::get('/shopClass/{id}', 'Home\ShopController@shopClass');
Route::get('/shopClass', 'Home\ShopController@ajaxSearch');
Route::get('/shop/search','Home\ShopController@search');

// 购物车
Route::get('/cart/index','Home\CartController@index');
Route::get('/cart/ajax','Home\CartController@ajax');

// 评论
Route::get('/comment/{gid}','Home\CommentController@index');
// 前台中间件路由群组
Route::group(['middleware' => 'homeLogin'],function(){
    // 个人中心
    Route::get('/home/user/space','Home\UserController@space');
    Route::get('/user/detail','Home\UserController@detail');
    Route::get('/user/address','Home\UserController@address');
    Route::post('/user/doAddress','Home\UserController@doAddress');
    Route::get('/user/delAddress/{id}','Home\UserController@delAddress');
    Route::get('/user/status','Home\UserController@status');

    Route::post('/user/update','Home\UserController@update');
    // 收藏
    Route::get('/user/favorite','Home\UserController@favorite');
    Route::get('/user/addFavorite','Home\UserController@addFavorite');
    Route::get('/user/delFavorite/{id}','Home\UserController@delFavorite');
    //订单
    Route::get('/order/index', 'Home\OrderController@order');
    Route::get('/order/ajax', 'Home\OrderController@ajax');
    Route::post('/order/tijiao', 'Home\OrderController@tijiao');
    Route::get('/order/zhifu', 'Home\OrderController@zhifu');

});
});
// 后台中间件路由群组
Route::group(['middleware' => 'login'],function(){

    //后台
    Route::get('/admin/index', 'Admin\IndexController@index');

    //用户管理
    Route::get('/admin/user/add', 'Admin\UserController@add');

    Route::post('/admin/user/insert', 'Admin\UserController@insert');
    Route::get('/admin/user/index', 'Admin\UserController@index');
    Route::post('admin/user/ajaxStatus','Admin\UserController@ajaxStatus');
    Route::post('/admin/user/ajaxAuth', 'Admin\UserController@ajaxAuth');
    Route::get('/admin/user/edit/{id}', 'Admin\UserController@edit');
    Route::post('/admin/user/update', 'Admin\UserController@update');
    Route::get('/admin/user/delete/{id}', 'Admin\UserController@delete');

    //分区分类管理
    Route::get('/admin/category/edit/{id}', 'Admin\CategoryController@edit');
    Route::post('/admin/category/ajaxStatus', 'Admin\CategoryController@ajaxStatus');
    Route::post('/admin/category/update/{id}', 'Admin\CategoryController@update');
    Route::resource('/admin/category', 'Admin\CategoryController');
    //商品分类管理

    Route::get('admin/shop/status/{gid}', 'Admin\ShopController@status');
    Route::get('admin/shop/delete/{gid}', 'Admin\ShopController@destroy');
    Route::get('admin/shop/doImgs/{gid}', 'Admin\ShopController@doImgs');
    Route::get('admin/shop/ajaxDelete', 'Admin\ShopController@ajaxDelete');
    Route::get('admin/shop/edit/{gid}', 'Admin\ShopController@edit');
    Route::get('admin/shop/out', 'Admin\ShopController@out');
    Route::post('admin/shop/imgs/{gid}', 'Admin\ShopController@imgs');
    Route::post('admin/shop/update/{gid}', 'Admin\ShopController@update');
    Route::resource('/admin/shop', 'Admin\ShopController');
    // 网站配置
    Route::get('/admin/config/index', 'Admin\ConfigController@index');
    Route::post('/admin/config/add', 'Admin\ConfigController@add');
    Route::get('/admin/config/ajax', 'Admin\ConfigController@ajax');

    // 评论管理
    Route::get('admin/comment/index','Admin\CommentController@index');
    Route::post('admin/comment/del','Admin\CommentController@del');
    Route::post('admin/comment/reply','Admin\CommentController@reply');

    // 订单管理
    Route::get('/admin/order/index','Admin\OrderController@index');
    Route::get('/admin/order/ajax','Admin\OrderController@ajax');
    Route::get('/admin/order/detail/{id}','Admin\OrderController@detail');
    Route::get('/admin/order/del/{id}','Admin\OrderController@del');
});

// 登录
Route::get('/admin/login','Admin\LoginController@login');
Route::post('/admin/doLogin','Admin\LoginController@dologin');
Route::get('/admin/logout','Admin\LoginController@logout');

// 验证码
Route::get('/admin/captcha/{tmp}','CodeController@captcha');